package userList.dao;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import userList.daomain.User;
import userList.util.JDBCUtils;

import java.util.List;

/**
 * @Author Administrator
 * @Date 2020/6/12 9:14
 * 使用Druid+JdbcTemplate
 **/
public class UserDaoDB implements UserDao {
    JdbcTemplate template =new JdbcTemplate(JDBCUtils.getDataSource());
    String sql="";
    @Override
    public List<User> findAll() {
        sql="select * from user2";
        try {
            List<User> list=template.query(sql,new BeanPropertyRowMapper<User>(User.class));
            return list;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public int delete(User user) {
        return 0;
    }

    @Override
    public int update(User user) {
        return 0;
    }
}
